<?php

use yii\helpers\Html;
use yii\grid\GridView;
use common\components\grid\GridView2015;
use kartik\popover\PopoverX;
use yii\bootstrap\Modal;

/* @var $this yii\web\View */
/* @var $searchModel common\models\searchs\SearchSysLog */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '日志管理';
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="sys-log-index">
    <?= common\components\grid\GridView2015::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
    	'title' => $this->title,
    	'panel' => [
    		'before' => Html::a('<i class="glyphicon glyphicon-remove"></i> 清空日志', ['clear', 'name' => f_get('name')], ['class' => 'btn btn-success', 'style' => 'margin-left:20px;'])
    	],
        'columns' => [
        	['class' => 'common\components\grid\CheckboxColumn2015'],
            ['class' => 'common\components\grid\SerialColumn2015'],
        	'_id',
            'level',
            'category',
            [
        		'class' => 'common\components\grid\DataColumn2015',
        		'attribute' => 'message',
        		'value' => function ($model, $key, $index, $column) {
    				return f_sub($model->message, 40, '');	
    			} 
        		
    		],
    		[
	    		'class' => 'common\components\grid\DataColumn2015',
	    		'attribute' => 'prefix',
	    		'value' => function ($model, $key, $index, $column) {
	    			return f_sub($model->prefix, 15, '');
	    		}
    		],
            [
	            'class' => 'common\components\grid\DataColumn2015',
	            'attribute' => 'log_time',
	            'filterType' => GridView2015::FILTER_DATE_RANGE,
	            'value' => function ($model, $key, $index, $column) {
	            	return date('Y-m-d H:i:s', $model->log_time);
	            }
            ],
            [
            	'class' => 'common\components\grid\ActionColumn2015',
            	'buttons' => [
            		'view' => function ($url, $model, $key) {
            			return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', 
            					f_url(['log/sys-log/view', 'name'=>get_class($model), 'id' => base64_encode($model->_id)]), [
            			]);
            		},	
            	],
            	'template' => '{view} {delete}',
    		]
        ],
    ]); ?>

</div>
